package com.ruoyi.web.controller.littleRedBook;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.littleRedBook.domain.pojo.Coupon;
import com.ruoyi.littleRedBook.service.CouponService;
import com.ruoyi.littleRedBook.service.CouponUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/couponUser")
public class CouponUserController {
    /**
     * 查询该用户的优惠券
     */
    @Autowired
    private CouponUserService couponUserService;
    @Autowired
    private CouponService couponService;
    @GetMapping("/{userId}")
    private AjaxResult list(@PathVariable Long userId){
        //根据userid查询出优惠券列表
        List<Coupon> coupons = couponService.getCouponsByUserId(userId);
        return AjaxResult.success(coupons);
    }

}
